package com.ethan.handler;

import com.ethan.enums.BizCodeEnum;
import com.ethan.util.CommonUtil;
import com.ethan.util.R;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Description: 登录失败
 * @Author ethan
 * @CreateDate:2022/3/21 14:44
 * @UpdateDate: 2021/6/17 08:52
 * @Version 1.0
 */
@Component
public class EAuthenticationEntryPointHandler implements AuthenticationEntryPoint {
    @Override
    public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException {
        CommonUtil.sendJsonMessage(response, R.buildResult(BizCodeEnum.OPS_401));
    }
}
